package de.koller.libration.scene.testscale;

import de.koller.aframe.util.math.Function2DPreview;
import de.koller.aframe.util.misc.ColorOperations;
import de.koller.aframe.util.noise.n2D.Noise2D;
import de.koller.libration.scene.Scene;
import de.koller.oceanFramework.gl.util.RasterManager;
import de.koller.oceanFramework.math.RVec3;

public class TestScale extends Scene {

	public TestScale() {
		super( 600, 600 );
		
		Noise2D n = new Noise2D( new float[][] { 
			{ 0, 0, 0, 0 },
			{ 0, 9, 9, 0 },
			{ 0, 9, 9, 0 },
			{ 0, 0, 0, 0 }
		} );
		
//		FunctionPreview.dontscale( -.1f );
//		FunctionPreview.showFunction( -1, 2, FunctionCutView.cutView2D( n, 0, .5f, 1, .5f ) );

		Function2DPreview.showFunction( 0, 0, 1, 1, n );
		
		RasterManager r = this.raster;
		for( int x = 0; x < r.getWidth(); x++ )
			for( int y = 0; y < r.getHeight(); y++ ) {
				RVec3 derivate = n.getDerivate( 1f / r.getWidth() * x, 1f / r.getHeight() * y );
				RVec3 light = new RVec3( 1, 0, 0 ).normalize();
				int a = 0xff_000000;
				int d = ColorOperations.diffuseLight( light, derivate, 0xff_ff0000, 0xff_ffffff );
				int s = ColorOperations.specularLight( light, derivate, new RVec3( 0, 0, 1 ), 0xff_808080, 0xff_808080, 30 );
				int c = ColorOperations.lightColor( 0xff_ff0000, a, d, s );
				
				r.setPixel( c, x, y );
			}
		
	}
	
}
